package com.jince.datacenter.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.log4j.Logger;

public class DateUtil {
	private final static Logger logger = Logger.getLogger(DateUtil.class);

	public static final String yyyyMMdd = "yyyyMMdd";
	
	public static String getDateToStr(String format,Date date){
		SimpleDateFormat sdf = new SimpleDateFormat(format);
		return sdf.format(date);
	}

	public static Date getStrToDate(String format,String dateStr){
		SimpleDateFormat sdf = new SimpleDateFormat(format);
		try {
			return sdf.parse(dateStr);
		} catch (ParseException e) {
			e.printStackTrace();
			logger.error(e, e);
		}
		return null;
	}
}
